cmake_minimum_required(VERSION 3.16)
project(AdyTools VERSION 0.1 LANGUAGES CXX)

#设置组件和应用程序名称
set(Component_Name AdyUI)
set(Application_Name AdyTools)

set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 6.2 COMPONENTS Quick REQUIRED)

# 是否开启构建AdyUI
set(Build_AdyUI OFF)
if(Build_AdyUI)
    add_subdirectory(AdyUI)
else()
    # 添加 AdyUI 库的路径和拷贝路径
    set(AdyUI_LIB_DIR "${CMAKE_SOURCE_DIR}/lib/AdyUI")
    set(AdyUI_DESTINATION_DIR "${CMAKE_BINARY_DIR}/Application/AdyUI")

    # 添加 AdyUI 库
    add_library(AdyUI STATIC IMPORTED)
    set_target_properties(AdyUI PROPERTIES
        IMPORTED_LOCATION "${AdyUI_LIB_DIR}/AdyUI.lib"
    )

    # 添加自定义目标来拷贝 AdyUI 目录
    add_custom_target(CopyAdyUI ALL
        COMMAND ${CMAKE_COMMAND} -E copy_directory
            ${AdyUI_LIB_DIR}
            ${AdyUI_DESTINATION_DIR}
        COMMENT "Copying AdyUI directory to build directory"
    )
endif()

add_subdirectory(Application)

# qt_add_executable(appAdyTools
#     main.cpp
# )

# qt_add_qml_module(appAdyTools
#     URI AdyTools
#     VERSION 1.0
#     QML_FILES main.qml
# )

# # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# # If you are developing for iOS or macOS you should consider setting an
# # explicit, fixed bundle identifier manually though.
# set_target_properties(appAdyTools PROPERTIES
# #    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appAdyTools
#     MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
#     MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
#     MACOSX_BUNDLE TRUE
#     WIN32_EXECUTABLE TRUE
# )

# target_link_libraries(appAdyTools
#     PRIVATE Qt6::Quick)

# include(GNUInstallDirs)
# install(TARGETS appAdyTools
#     BUNDLE DESTINATION .
#     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
